package com.qifenqian.turbot.module.adapter.marketing

import android.support.v7.widget.GridLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.qifenqian.turbot.R
import com.qifenqian.turbot.module.adapter.itemdecoration.GridItemDecoration
import com.qifenqian.turbot.module.ui.marketing.ACTION_DISCOUNT_EDIT
import com.qifenqian.turbot.module.ui.marketing.DiscountDishEditActivity
import kotlinx.android.synthetic.main.item_discount_dish.view.*

/**
 * @author H
 * @createTime 2019/1/3 17:04
 * @description
 * @see
 * @since
 */
class DiscountDishAdapter(list: List<String>) : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_discount_dish, list) {

    var childList = mutableListOf("1", "2", "3", "4")
    override fun convert(helper: BaseViewHolder?, item: String?) {
        val view = helper!!.itemView
        view.tv_item_discount_dish_time.text = item
        view.tv_item_discount_dish_use_type.text = "单用"
        view.rv_item_discount_dish.layoutManager = GridLayoutManager(mContext, 3)
        val discountDishChildAdapter = DiscountDishChildAdapter(mContext, childList)
        view.rv_item_discount_dish.addItemDecoration(GridItemDecoration(mContext, 16))
        view.rv_item_discount_dish.adapter = discountDishChildAdapter
        discountDishChildAdapter.setOnDishDiscountClickListener(object : DiscountDishChildAdapter.OnDishDiscountClickListener {
            override fun onClick(position: Int) {
                DiscountDishEditActivity.startThis(mContext, ACTION_DISCOUNT_EDIT, childList[position])
            }
        })

    }
}